
#import "Capsule.h"
#import "GameManager.h"

@implementation Capsule

/*
 Vertex x-Range from: -3.6 to: 3.5
 Vertex y-Range from: -3.5 to: 3.6
 Vertex z-Range from: -8.7 to: 8.6
 
 Suggested radius for bounding sphere: 5.3
*/ 

- (void) additionalSetup {
    type = CAPSULE;          
    radius = 5.3;
    
    GLfloat verticesObjData[ ] = {    
        -0.1, 0.0, 8.6, 0.9, 0.0, 8.5, 0.7, 0.5, 8.5, 0.4, 0.8, 8.5, -0.1, 1.0, 8.5, -0.5, 0.8, 8.5, -0.8, 0.5, 8.5, -1.0, 0.0, 8.5, -0.8, -0.4, 8.5, -0.5, -0.8, 8.5, -0.1, -0.9, 8.5, 0.4, -0.8, 8.5, 0.7, -0.4, 8.5, 1.7, 0.0, 8.1, 1.5, 0.9, 8.1, 0.8, 1.6, 8.1, -0.1, 1.8, 8.1, -0.9, 1.6, 8.1, -1.6, 0.9, 8.1, -1.8, 0.0, 8.1, -1.6, -0.8, 8.1, -0.9, -1.5, 8.1, -0.1, -1.7, 8.1, 0.8, -1.5, 8.1, 1.5, -0.8, 8.1, 2.5, 0.0, 7.5, 2.1, 1.3, 7.5, 1.2, 2.2, 7.5, -0.1, 2.5, 7.5, -1.3, 2.2, 7.5, -2.2, 1.3, 7.5, -2.6, 0.0, 7.5, -2.2, -1.2, 7.5, -1.3, -2.1, 7.5, -0.1, -2.5, 7.5, 1.2, -2.1, 7.5, 2.1, -1.2, 7.5, 3.0, 0.0, 6.8, 2.6, 1.6, 6.8, 1.5, 2.7, 6.8, -0.1, 3.1, 6.8, -1.6, 2.7, 6.8, -2.7, 1.6, 6.8, -3.1, 0.0, 6.8, -2.7, -1.5, 6.8, -1.6, -2.6, 6.8, -0.1, -3.0, 6.8, 1.5, -2.6, 6.8, 2.6, -1.5, 6.8, 3.4, 0.0, 6.0, 2.9, 1.8, 6.0, 1.7, 3.0, 6.0, -0.1, 3.5, 6.0, -1.8, 3.0, 6.0, -3.0, 1.8, 6.0, -3.5, 0.0, 6.0, -3.0, -1.7, 6.0, -1.8, -2.9, 6.0, -0.1, -3.4, 6.0, 1.7, -2.9, 6.0, 2.9, -1.7, 6.0, 3.5, 0.0, 5.0, 3.0, 1.8, 5.0, 1.7, 3.1, 5.0, -0.1, 3.6, 5.0, -1.8, 3.1, 5.0, -3.1, 1.8, 5.0, -3.6, 0.0, 5.0, -3.1, -1.7, 5.0, -1.8, -3.0, 5.0, -0.1, -3.5, 5.0, 1.7, -3.0, 5.0, 3.0, -1.7, 5.0, 3.5, 0.0, -5.1, 3.0, 1.8, -5.1, 1.7, 3.1, -5.1, -0.1, 3.6, -5.1, -1.8, 3.1, -5.1, -3.1, 1.8, -5.1, -3.6, 0.0, -5.1, -3.1, -1.7, -5.1, -1.8, -3.0, -5.1, -0.1, -3.5, -5.1, 1.7, -3.0, -5.1, 3.0, -1.7, -5.1, 3.4, 0.0, -6.0, 2.9, 1.8, -6.0, 1.7, 3.0, -6.0, -0.1, 3.5, -6.0, -1.8, 3.0, -6.0, -3.0, 1.8, -6.0, -3.5, 0.0, -6.0, -3.0, -1.7, -6.0, -1.8, -2.9, -6.0, -0.1, -3.4, -6.0, 1.7, -2.9, -6.0, 2.9, -1.7, -6.0, 3.0, 0.0, -6.9, 2.6, 1.6, -6.9, 1.5, 2.7, -6.9, -0.1, 3.1, -6.9, -1.6, 2.7, -6.9, -2.7, 1.6, -6.9, -3.1, 0.0, -6.9, -2.7, -1.5, -6.9, -1.6, -2.6, -6.9, -0.1, -3.0, -6.9, 1.5, -2.6, -6.9, 2.6, -1.5, -6.9, 2.5, 0.0, -7.6, 2.1, 1.3, -7.6, 1.2, 2.2, -7.6, -0.1, 2.5, -7.6, -1.3, 2.2, -7.6, -2.2, 1.3, -7.6, -2.6, 0.0, -7.6, -2.2, -1.2, -7.6, -1.3, -2.1, -7.6, -0.1, -2.5, -7.6, 1.2, -2.1, -7.6, 2.1, -1.2, -7.6, 1.7, 0.0, -8.2, 1.5, 0.9, -8.2, 0.8, 1.6, -8.2, -0.1, 1.8, -8.2, -0.9, 1.6, -8.2, -1.6, 0.9, -8.2, -1.8, 0.0, -8.2, -1.6, -0.8, -8.2, -0.9, -1.5, -8.2, -0.1, -1.7, -8.2, 0.8, -1.5, -8.2, 1.5, -0.8, -8.2, 0.9, 0.0, -8.6, 0.7, 0.5, -8.6, 0.4, 0.8, -8.6, -0.1, 1.0, -8.6, -0.5, 0.8, -8.6, -0.8, 0.5, -8.6, -1.0, 0.0, -8.6, -0.8, -0.4, -8.6, -0.5, -0.8, -8.6, -0.1, -0.9, -8.6, 0.4, -0.8, -8.6, 0.7, -0.4, -8.6, -0.1, 0.0, -8.7
    };    
    
    GLfloat normalsObjData[ ] = {
        -0.0, -0.0, 1.0, 0.3, 0.0, 1.0, 0.2, 0.1, 1.0, 0.1, 0.2, 1.0, -0.0, 0.3, 1.0, -0.1, 0.2, 1.0, -0.2, 0.1, 1.0, -0.3, -0.0, 1.0, -0.2, -0.1, 1.0, -0.1, -0.2, 1.0, 0.0, -0.3, 1.0, 0.1, -0.2, 1.0, 0.2, -0.1, 1.0, 0.5, 0.0, 0.9, 0.4, 0.3, 0.9, 0.3, 0.4, 0.9, -0.0, 0.5, 0.9, -0.3, 0.4, 0.9, -0.4, 0.3, 0.9, -0.5, -0.0, 0.9, -0.4, -0.3, 0.9, -0.3, -0.4, 0.9, 0.0, -0.5, 0.9, 0.3, -0.4, 0.9, 0.4, -0.3, 0.9, 0.7, 0.0, 0.7, 0.6, 0.4, 0.7, 0.4, 0.6, 0.7, -0.0, 0.7, 0.7, -0.4, 0.6, 0.7, -0.6, 0.4, 0.7, -0.7, -0.0, 0.7, -0.6, -0.4, 0.7, -0.4, -0.6, 0.7, 0.0, -0.7, 0.7, 0.4, -0.6, 0.7, 0.6, -0.4, 0.7, 0.9, 0.0, 0.5, 0.8, 0.4, 0.5, 0.4, 0.8, 0.5, -0.0, 0.9, 0.5, -0.4, 0.8, 0.5, -0.8, 0.4, 0.5, -0.9, -0.0, 0.5, -0.8, -0.4, 0.5, -0.4, -0.8, 0.5, 0.0, -0.9, 0.5, 0.4, -0.8, 0.5, 0.8, -0.4, 0.5, 1.0, 0.0, 0.3, 0.8, 0.5, 0.3, 0.5, 0.8, 0.3, -0.0, 1.0, 0.3, -0.5, 0.8, 0.3, -0.8, 0.5, 0.3, -1.0, -0.0, 0.3, -0.8, -0.5, 0.3, -0.5, -0.8, 0.3, 0.0, -1.0, 0.3, 0.5, -0.8, 0.3, 0.8, -0.5, 0.3, 1.0, 0.0, 0.1, 0.9, 0.5, 0.1, 0.5, 0.9, 0.1, -0.0, 1.0, 0.1, -0.5, 0.9, 0.1, -0.9, 0.5, 0.1, -1.0, -0.0, 0.1, -0.9, -0.5, 0.1, -0.5, -0.9, 0.1, 0.0, -1.0, 0.1, 0.5, -0.9, 0.1, 0.9, -0.5, 0.1, 1.0, 0.0, -0.1, 0.9, 0.5, -0.1, 0.5, 0.9, -0.1, -0.0, 1.0, -0.1, -0.5, 0.9, -0.1, -0.9, 0.5, -0.1, -1.0, -0.0, -0.1, -0.9, -0.5, -0.1, -0.5, -0.9, -0.1, 0.0, -1.0, -0.1, 0.5, -0.9, -0.1, 0.9, -0.5, -0.1, 1.0, 0.0, -0.3, 0.8, 0.5, -0.3, 0.5, 0.8, -0.3, -0.0, 1.0, -0.3, -0.5, 0.8, -0.3, -0.8, 0.5, -0.3, -1.0, -0.0, -0.3, -0.8, -0.5, -0.3, -0.5, -0.8, -0.3, 0.0, -1.0, -0.3, 0.5, -0.8, -0.3, 0.8, -0.5, -0.3, 0.9, 0.0, -0.5, 0.8, 0.4, -0.5, 0.4, 0.8, -0.5, -0.0, 0.9, -0.5, -0.4, 0.8, -0.5, -0.8, 0.4, -0.5, -0.9, -0.0, -0.5, -0.8, -0.4, -0.5, -0.4, -0.8, -0.5, 0.0, -0.9, -0.5, 0.4, -0.8, -0.5, 0.8, -0.4, -0.5, 0.7, 0.0, -0.7, 0.6, 0.4, -0.7, 0.4, 0.6, -0.7, -0.0, 0.7, -0.7, -0.4, 0.6, -0.7, -0.6, 0.4, -0.7, -0.7, -0.0, -0.7, -0.6, -0.4, -0.7, -0.4, -0.6, -0.7, 0.0, -0.7, -0.7, 0.4, -0.6, -0.7, 0.6, -0.4, -0.7, 0.5, 0.0, -0.9, 0.4, 0.3, -0.9, 0.3, 0.4, -0.9, -0.0, 0.5, -0.9, -0.3, 0.4, -0.9, -0.4, 0.3, -0.9, -0.5, -0.0, -0.9, -0.4, -0.3, -0.9, -0.3, -0.4, -0.9, 0.0, -0.5, -0.9, 0.3, -0.4, -0.9, 0.4, -0.3, -0.9, 0.3, 0.0, -1.0, 0.2, 0.1, -1.0, 0.1, 0.2, -1.0, -0.0, 0.3, -1.0, -0.1, 0.2, -1.0, -0.2, 0.1, -1.0, -0.3, -0.0, -1.0, -0.2, -0.1, -1.0, -0.1, -0.2, -1.0, 0.0, -0.3, -1.0, 0.1, -0.2, -1.0, 0.2, -0.1, -1.0, -0.0, -0.0, -1.0
    };
    
    GLushort facesObjData[ ] = { 
        0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8, 0, 8, 9, 0, 9, 10, 0, 10, 11, 0, 11, 12, 0, 12, 1, 1, 13, 14, 1, 14, 2, 2, 14, 15, 2, 15, 3, 3, 15, 16, 3, 16, 4, 4, 16, 17, 4, 17, 5, 5, 17, 18, 5, 18, 6, 6, 18, 19, 6, 19, 7, 7, 19, 20, 7, 20, 8, 8, 20, 21, 8, 21, 9, 9, 21, 22, 9, 22, 10, 10, 22, 23, 10, 23, 11, 11, 23, 24, 11, 24, 12, 12, 24, 13, 12, 13, 1, 13, 25, 26, 13, 26, 14, 14, 26, 27, 14, 27, 15, 15, 27, 28, 15, 28, 16, 16, 28, 29, 16, 29, 17, 17, 29, 30, 17, 30, 18, 18, 30, 31, 18, 31, 19, 19, 31, 32, 19, 32, 20, 20, 32, 33, 20, 33, 21, 21, 33, 34, 21, 34, 22, 22, 34, 35, 22, 35, 23, 23, 35, 36, 23, 36, 24, 24, 36, 25, 24, 25, 13, 25, 37, 38, 25, 38, 26, 26, 38, 39, 26, 39, 27, 27, 39, 40, 27, 40, 28, 28, 40, 41, 28, 41, 29, 29, 41, 42, 29, 42, 30, 30, 42, 43, 30, 43, 31, 31, 43, 44, 31, 44, 32, 32, 44, 45, 32, 45, 33, 33, 45, 46, 33, 46, 34, 34, 46, 47, 34, 47, 35, 35, 47, 48, 35, 48, 36, 36, 48, 37, 36, 37, 25, 37, 49, 50, 37, 50, 38, 38, 50, 51, 38, 51, 39, 39, 51, 52, 39, 52, 40, 40, 52, 53, 40, 53, 41, 41, 53, 54, 41, 54, 42, 42, 54, 55, 42, 55, 43, 43, 55, 56, 43, 56, 44, 44, 56, 57, 44, 57, 45, 45, 57, 58, 45, 58, 46, 46, 58, 59, 46, 59, 47, 47, 59, 60, 47, 60, 48, 48, 60, 49, 48, 49, 37, 49, 61, 62, 49, 62, 50, 50, 62, 63, 50, 63, 51, 51, 63, 64, 51, 64, 52, 52, 64, 65, 52, 65, 53, 53, 65, 66, 53, 66, 54, 54, 66, 67, 54, 67, 55, 55, 67, 68, 55, 68, 56, 56, 68, 69, 56, 69, 57, 57, 69, 70, 57, 70, 58, 58, 70, 71, 58, 71, 59, 59, 71, 72, 59, 72, 60, 60, 72, 61, 60, 61, 49, 61, 73, 74, 61, 74, 62, 62, 74, 75, 62, 75, 63, 63, 75, 76, 63, 76, 64, 64, 76, 77, 64, 77, 65, 65, 77, 78, 65, 78, 66, 66, 78, 79, 66, 79, 67, 67, 79, 80, 67, 80, 68, 68, 80, 81, 68, 81, 69, 69, 81, 82, 69, 82, 70, 70, 82, 83, 70, 83, 71, 71, 83, 84, 71, 84, 72, 72, 84, 73, 72, 73, 61, 73, 85, 86, 73, 86, 74, 74, 86, 87, 74, 87, 75, 75, 87, 88, 75, 88, 76, 76, 88, 89, 76, 89, 77, 77, 89, 90, 77, 90, 78, 78, 90, 91, 78, 91, 79, 79, 91, 92, 79, 92, 80, 80, 92, 93, 80, 93, 81, 81, 93, 94, 81, 94, 82, 82, 94, 95, 82, 95, 83, 83, 95, 96, 83, 96, 84, 84, 96, 85, 84, 85, 73, 85, 97, 98, 85, 98, 86, 86, 98, 99, 86, 99, 87, 87, 99, 100, 87, 100, 88, 88, 100, 101, 88, 101, 89, 89, 101, 102, 89, 102, 90, 90, 102, 103, 90, 103, 91, 91, 103, 104, 91, 104, 92, 92, 104, 105, 92, 105, 93, 93, 105, 106, 93, 106, 94, 94, 106, 107, 94, 107, 95, 95, 107, 108, 95, 108, 96, 96, 108, 97, 96, 97, 85, 97, 109, 110, 97, 110, 98, 98, 110, 111, 98, 111, 99, 99, 111, 112, 99, 112, 100, 100, 112, 113, 100, 113, 101, 101, 113, 114, 101, 114, 102, 102, 114, 115, 102, 115, 103, 103, 115, 116, 103, 116, 104, 104, 116, 117, 104, 117, 105, 105, 117, 118, 105, 118, 106, 106, 118, 119, 106, 119, 107, 107, 119, 120, 107, 120, 108, 108, 120, 109, 108, 109, 97, 109, 121, 122, 109, 122, 110, 110, 122, 123, 110, 123, 111, 111, 123, 124, 111, 124, 112, 112, 124, 125, 112, 125, 113, 113, 125, 126, 113, 126, 114, 114, 126, 127, 114, 127, 115, 115, 127, 128, 115, 128, 116, 116, 128, 129, 116, 129, 117, 117, 129, 130, 117, 130, 118, 118, 130, 131, 118, 131, 119, 119, 131, 132, 119, 132, 120, 120, 132, 121, 120, 121, 109, 121, 133, 134, 121, 134, 122, 122, 134, 135, 122, 135, 123, 123, 135, 136, 123, 136, 124, 124, 136, 137, 124, 137, 125, 125, 137, 138, 125, 138, 126, 126, 138, 139, 126, 139, 127, 127, 139, 140, 127, 140, 128, 128, 140, 141, 128, 141, 129, 129, 141, 142, 129, 142, 130, 130, 142, 143, 130, 143, 131, 131, 143, 144, 131, 144, 132, 132, 144, 133, 132, 133, 121, 133, 145, 134, 134, 145, 135, 135, 145, 136, 136, 145, 137, 137, 145, 138, 138, 145, 139, 139, 145, 140, 140, 145, 141, 141, 145, 142, 142, 145, 143, 143, 145, 144, 144, 145, 133
    };
    
    [self setVertices: verticesObjData
                 size: sizeof(verticesObjData) 
         setTexCoords: nil
                 size: 0
           setNormals: normalsObjData
                 size: sizeof(normalsObjData)
             setFaces: facesObjData
                 size: sizeof(facesObjData)];    
}

- (void) setColor {
    glColor4f(0.5, 0.5, 0.5, 1);
}

@end